// import dragTable from './dragTable'
function install(Vue) {
    // 多个指令的注册
    'dragTable.name'
    Vue.directive('drag', {
        inserted(el, binding, vnode) {
            let head = el.querySelector('div.el-table__header-wrapper');
            let target = el.querySelector('div.el-table__body-wrapper');

            head.style.cursor = target.style.cursor = 'grab';
            target.style.overflow = 'hidden';

            head.onmousedown = target.onmousedown = function (e) {
                let startX = e.clientX;
                console.log(startX,"点击位置");
                // 当前滚动值
                let originalScrollX = target.scrollLeft;

                // 点击以后的移动
                document.onmousemove = function (e) {
                    console.log(e.clientX,'移动到了x');
                    let subs = e.clientX - startX;
                    // 变更卷入
                    head.scrollLeft = target.scrollLeft = originalScrollX - subs;
                    console.log('head.scollLeft:',head.scrollLeft)
                }
                // 鼠标抬起释放事件
                document.onmouseup = function(){
                    document.onmousemove = document.onmouseup = null;
                }

            }
        },
        unbind(el, binding, vnode) {
            let head = el.querySelector('div.el-table__header-wrapper');
            let target = el.querySelector('div.el-table__body-wrapper');
            head.onmousedown = target.onmousedown = null;
        }
    })
}
export default {
    install
}

// Vue.use